package com.smartfast4j.backend.modules.sys.controller;


import com.smartfast4j.backend.common.bean.R;
import com.smartfast4j.backend.common.controller.WebBaseController;
import com.smartfast4j.backend.modules.sys.entity.SysMenu;
import com.smartfast4j.backend.modules.sys.entity.SysUser;
import com.smartfast4j.backend.modules.sys.service.SysMenuService;
import com.smartfast4j.backend.modules.sys.vo.SysMenuVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 菜单管理 前端控制器
 * </p>
 *
 * @author 孤傲苍狼
 * @since 2017-09-05
 */
@RestController
@RequestMapping("/sys/sysMenu")
public class SysMenuController extends WebBaseController{

    @Autowired
    private SysMenuService sysMenuService;

    @RequestMapping("/getSysMenuList")
    public List<SysMenu> getSysMenuList() {
        List<SysMenu> sysMenuList = sysMenuService.selectByMap(null);
        return sysMenuList;
    }

    /**
     * 用户菜单列表
     */
    @RequestMapping("/user")
    public R user(){
        /**
         * 根据登录用户ID获取用户菜单列表
         */
        List<SysMenuVo> menuList = sysMenuService.getUserMenuList(getSysLoginUserId());
        return R.ok().put("menuList", menuList);
    }
}
